package com.jdbc.utils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class TestSelect {
    public static void main(String[] args) {
        Connection conn = null;
        Statement st = null;
        ResultSet rs = null;
        try {
            conn = JdbcUtils.getConnection();//获取数据库连接
            st = conn.createStatement();
            String sql = "select * from `users`";
            rs = st.executeQuery(sql);
            while(rs.next()){
                System.out.println("id="+ rs.getObject("id"));
                System.out.println("name="+ rs.getObject("NAME"));
                System.out.println("email="+ rs.getObject("email"));
                System.out.println("birthday="+ rs.getObject("birthday"));
                System.out.println("=============================");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            JdbcUtils.release(conn,st,rs);
        }
    }
}


